package biznussoft.metercor.fragments;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TableLayout;
import biznussoft.metercor.HomeActivity;
import biznussoft.metercor.R;
import biznussoft.metercor.lookup.AccountLookup;
import biznussoft.metercor.lookup.TechicianNameLookup;
import biznussoft.metercor.model.Bean_Class;
import biznussoft.metercor.utils.Session;

import com.salesforce.androidsdk.rest.RestClient;
import com.salesforce.androidsdk.rest.RestClient.AsyncRequestCallback;
import com.salesforce.androidsdk.rest.RestRequest;
import com.salesforce.androidsdk.rest.RestResponse;
import com.salesforce.androidsdk.util.EventsObservable;
import com.salesforce.androidsdk.util.EventsObservable.EventType;

public class NewJobsiteInspectionCheckListFragmnet extends Fragment implements
OnClickListener {

	private CheckBox cb1, cb2, cb3, cb21, cb22, cb23, cb31, cb32, cb33, cb41,
	cb42, cb43, cb51, cb52, cb53, cb61, cb62, cb63, cb71, cb72, cb73,
	cb81, cb82, cb83, cb91, cb92, cb93, cb101, cb102, cb103, cb111,
	cb112, cb113, cb121, cb122, cb123, cb131, cb132, cb133, sClean,
	nsClean, naClean, sAdequate, nsAdequate, naAdequate,
	sAdequateLadders, nsAdequateLadders, naAdequateLadders, sother,
	nsother, naother, sWalkways, nsWalkways, naWalkways, sClearWork,
	nsClearWork, naClearWork, sAccessandLanding, nsAccessandLanding,
	naAccessandLanding, sOther2, nsOther2, naOther2, sHead, nsHead,
	naHead, sFoot, nsFoot, naFoot, sEye, nsEye, naEye, sHearing,
	nsHearing, naHearing, sRespiratory, nsRespiratory, naRespiratory,
	sfall, nsFall, naFall, sOther3, nsOther3, naOther3, sGeneral,
	nsGeneral, naGeneral, sProper, nsProper, naProper, sOther4,
	nsOther4, naOther4, sLighting, nsLighting, naLighting, sHandRails,
	nsHandRails, naHandRails, sOther5, nsOther5, naOther5, sCProper,
	nsCproper, naCProper, sAir, nsAir, naAir, sRescue, naRescue,
	nsRescue, sSafety, nsSafety, naSafety, sSecond, nsSecond, naSecond,
	sOutGoing, nsOutGoing, naOutGoing, sPermit, nsPermit, naPermit,
	sOther6, nsOther6, naOther6, sMaster, nsMaster, naMaster,
	sExtinguishers, nsExtinguishers, naExtinguishers, sFully, nsFully,
	naFully, sAdequately, nsAdequately, naAdequately, sOther8,
	nsOther8, naOther8,sRods,nsRods,naRods,sMSDs,nsMSDs,naMSDs,sProperly,nsProperly,naProperly,sProper2,nsProper2,naProper2,sexhaust
	,nsexhaust,naexhaust,scylinders,nscylinders,nacylinders,sExtiguisher,nsExtiguisher,naExtiguisher,sOther9,nsOther9,naOther9,sOutdoor,nsOutdoor,naOutdoor
	,sCondition,nsCondition,naCondition,sProperly2,nsProperly2,naProperly2,sGFCIs,nsGFCIs,naGFCIs,
	sOther10,naOther10,nsOther10;
	private Button submit;
	public static EditText etEmployeeName, etLocation, etConducted;
	private EditText etNo_of_employees, etdate;
	private RestClient client;
	private TableLayout ttSiteAcess, ttHousekepping,
	ttpersonalProtectiveEquipment, ttPowerTools, ttStairwells,
	ttConfinedspaces, ttFireProtection, ttWelding, ttExtension,
	ttMaterials, ttSignsandPrint, ttWorker, ttHygiene;
	private ImageView imSiteAcess, imHousekepping,
	impersonalProtectiveEquipment, imPowerTools, imStairwells,
	imConfinedspaces, imFireProtection, imWelding, imExtension,
	imMaterials, imSignsandPrint, imWorker, imHygiene;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.jobchecklist_main, null);
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);

		client = HomeActivity.mActivity.client;
		Bean_Class.api_Version = getString(R.string.api_version);
		etEmployeeName = (EditText) getView().findViewById(R.id.etEmployee);
		etLocation = (EditText) getView().findViewById(R.id.etLocation);
		etConducted = (EditText) getView().findViewById(R.id.etConductedBy);
		etNo_of_employees = (EditText) getView().findViewById(
				R.id.etnoofemployees);
		etdate = (EditText) getView().findViewById(R.id.etdate);
		Calendar c = Calendar.getInstance();
		SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
		etdate.setText(df.format(c.getTime()));

		ttSiteAcess = (TableLayout) getView().findViewById(R.id.ttSiteAccess);
		ttHousekepping = (TableLayout) getView().findViewById(
				R.id.tthousekepping);
		ttpersonalProtectiveEquipment = (TableLayout) getView().findViewById(
				R.id.ttpersonalprotect);
		ttPowerTools = (TableLayout) getView().findViewById(R.id.ttpowerTools);
		ttStairwells = (TableLayout) getView().findViewById(
				R.id.ttstairwellsandramps);
		ttConfinedspaces = (TableLayout) getView().findViewById(
				R.id.ttconfinedSpaces);
		ttFireProtection = (TableLayout) getView().findViewById(
				R.id.ttFireprotection);
		ttWelding = (TableLayout) getView().findViewById(R.id.ttwelding);
		ttExtension = (TableLayout) getView().findViewById(
				R.id.ttExtensionCords);
		ttSignsandPrint = (TableLayout) getView().findViewById(
				R.id.ttSignandPrint);
		ttWorker = (TableLayout) getView().findViewById(R.id.ttWorkEducation);
		ttHygiene = (TableLayout) getView().findViewById(R.id.ttHygine);
		ttMaterials = (TableLayout) getView().findViewById(
				R.id.ttMaterialStorage);

		imSiteAcess = (ImageView) getView().findViewById(R.id.imageView1);
		imHousekepping = (ImageView) getView().findViewById(R.id.imageView2);
		impersonalProtectiveEquipment = (ImageView) getView().findViewById(
				R.id.imageView3);
		imPowerTools = (ImageView) getView().findViewById(R.id.imageView4);
		imStairwells = (ImageView) getView().findViewById(R.id.imageView5);
		imConfinedspaces = (ImageView) getView().findViewById(R.id.imageView6);
		imFireProtection = (ImageView) getView().findViewById(R.id.imageView7);
		imWelding = (ImageView) getView().findViewById(R.id.imageView8);
		imExtension = (ImageView) getView().findViewById(R.id.imageView9);
		imMaterials = (ImageView) getView().findViewById(R.id.imageView10);
		imSignsandPrint = (ImageView) getView().findViewById(R.id.imageView11);
		imWorker = (ImageView) getView().findViewById(R.id.imageView12);
		imHygiene = (ImageView) getView().findViewById(R.id.imageView13);

		imSiteAcess.setOnClickListener(this);
		imHousekepping.setOnClickListener(this);
		impersonalProtectiveEquipment.setOnClickListener(this);
		imPowerTools.setOnClickListener(this);
		imStairwells.setOnClickListener(this);
		imConfinedspaces.setOnClickListener(this);
		imFireProtection.setOnClickListener(this);
		imWelding.setOnClickListener(this);
		imExtension.setOnClickListener(this);
		imMaterials.setOnClickListener(this);
		imSignsandPrint.setOnClickListener(this);
		imWorker.setOnClickListener(this);
		imHygiene.setOnClickListener(this);

		cb1 = (CheckBox) getView().findViewById(R.id.cb1);
		cb2 = (CheckBox) getView().findViewById(R.id.cb2);
		cb3 = (CheckBox) getView().findViewById(R.id.cb3);

		cb21 = (CheckBox) getView().findViewById(R.id.cb21);
		cb22 = (CheckBox) getView().findViewById(R.id.cb22);
		cb23 = (CheckBox) getView().findViewById(R.id.cb23);
		sClean = (CheckBox) getView().findViewById(R.id.sClean);
		nsClean = (CheckBox) getView().findViewById(R.id.nsClean);
		naClean = (CheckBox) getView().findViewById(R.id.naClean);
		sAdequate = (CheckBox) getView().findViewById(R.id.sAdequate);
		nsAdequate = (CheckBox) getView().findViewById(R.id.nsAdequate);
		naAdequate = (CheckBox) getView().findViewById(R.id.naAdequate);
		sAdequateLadders = (CheckBox) getView().findViewById(
				R.id.sAdequateLadders);
		nsAdequateLadders = (CheckBox) getView().findViewById(
				R.id.nsAdequateLadders);
		naAdequateLadders = (CheckBox) getView().findViewById(
				R.id.naAdequateLadders);
		sother = (CheckBox) getView().findViewById(R.id.sOther);
		nsother = (CheckBox) getView().findViewById(R.id.nsOther);
		naother = (CheckBox) getView().findViewById(R.id.naOther);

		cb31 = (CheckBox) getView().findViewById(R.id.cb31);
		cb32 = (CheckBox) getView().findViewById(R.id.cb32);
		cb33 = (CheckBox) getView().findViewById(R.id.cb33);
		sWalkways = (CheckBox) getView().findViewById(R.id.swalkways);
		nsWalkways = (CheckBox) getView().findViewById(R.id.nswalkways);
		naWalkways = (CheckBox) getView().findViewById(R.id.nawalkways);
		sClearWork = (CheckBox) getView().findViewById(R.id.sClearwork);
		nsClearWork = (CheckBox) getView().findViewById(R.id.nsClearwork);
		naClearWork = (CheckBox) getView().findViewById(R.id.naClearwork);
		sAccessandLanding = (CheckBox) getView().findViewById(
				R.id.saccessandlanding);
		nsAccessandLanding = (CheckBox) getView().findViewById(
				R.id.nsaccessandlanding);
		naAccessandLanding = (CheckBox) getView().findViewById(
				R.id.naaccessandlanding);
		sOther2 = (CheckBox) getView().findViewById(R.id.sOther2);
		nsOther2 = (CheckBox) getView().findViewById(R.id.nsOther2);
		naOther2 = (CheckBox) getView().findViewById(R.id.naOther2);

		sHead = (CheckBox) getView().findViewById(R.id.sHead);
		nsHead = (CheckBox) getView().findViewById(R.id.nsHead);
		naHead = (CheckBox) getView().findViewById(R.id.naHead);
		sFoot = (CheckBox) getView().findViewById(R.id.sFoot);
		nsFoot = (CheckBox) getView().findViewById(R.id.nsFoot);
		naFoot = (CheckBox) getView().findViewById(R.id.naFoot);
		sEye = (CheckBox) getView().findViewById(R.id.sEye);
		nsEye = (CheckBox) getView().findViewById(R.id.nsEye);
		naEye = (CheckBox) getView().findViewById(R.id.naEye);
		sHearing = (CheckBox) getView().findViewById(R.id.sHearing);
		nsHearing = (CheckBox) getView().findViewById(R.id.nsHearing);
		naHearing = (CheckBox) getView().findViewById(R.id.naHearing);
		sRespiratory = (CheckBox) getView().findViewById(R.id.sRespiratory);
		nsRespiratory = (CheckBox) getView().findViewById(R.id.nsRespiratory);
		naRespiratory = (CheckBox) getView().findViewById(R.id.naRespiratory);
		sfall = (CheckBox) getView().findViewById(R.id.sFall);
		nsFall = (CheckBox) getView().findViewById(R.id.nsFall);
		naFall = (CheckBox) getView().findViewById(R.id.naFall);
		sOther3 = (CheckBox) getView().findViewById(R.id.sOther3);
		nsOther3 = (CheckBox) getView().findViewById(R.id.nsOther3);
		naOther3 = (CheckBox) getView().findViewById(R.id.naOther3);

		cb41 = (CheckBox) getView().findViewById(R.id.cb41);
		cb42 = (CheckBox) getView().findViewById(R.id.cb42);
		cb43 = (CheckBox) getView().findViewById(R.id.cb43);
		sGeneral = (CheckBox) getView().findViewById(R.id.sGeneral);
		nsGeneral = (CheckBox) getView().findViewById(R.id.nsGeneral);
		naGeneral = (CheckBox) getView().findViewById(R.id.naGeneral);
		sProper = (CheckBox) getView().findViewById(R.id.sProper);
		nsProper = (CheckBox) getView().findViewById(R.id.nsProper);
		naProper = (CheckBox) getView().findViewById(R.id.naProper);
		sOther4 = (CheckBox) getView().findViewById(R.id.sOther4);
		nsOther4 = (CheckBox) getView().findViewById(R.id.nsOther4);
		naOther4 = (CheckBox) getView().findViewById(R.id.naOther4);

		cb51 = (CheckBox) getView().findViewById(R.id.cb51);
		cb52 = (CheckBox) getView().findViewById(R.id.cb52);
		cb53 = (CheckBox) getView().findViewById(R.id.cb53);
		sLighting = (CheckBox) getView().findViewById(R.id.sLighting);
		nsLighting = (CheckBox) getView().findViewById(R.id.nsLighting);
		naLighting = (CheckBox) getView().findViewById(R.id.naLighting);
		sHandRails = (CheckBox) getView().findViewById(R.id.sHandrails);
		nsHandRails = (CheckBox) getView().findViewById(R.id.nsHandrails);
		naHandRails = (CheckBox) getView().findViewById(R.id.naHandrails);
		sOther5 = (CheckBox) getView().findViewById(R.id.sOther5);
		nsOther5 = (CheckBox) getView().findViewById(R.id.nsOther5);
		naOther5 = (CheckBox) getView().findViewById(R.id.naOther5);

		cb61 = (CheckBox) getView().findViewById(R.id.cb61);
		cb62 = (CheckBox) getView().findViewById(R.id.cb62);
		cb63 = (CheckBox) getView().findViewById(R.id.cb63);
		sCProper = (CheckBox) getView().findViewById(R.id.sProper);
		nsCproper = (CheckBox) getView().findViewById(R.id.nsProper);
		naCProper = (CheckBox) getView().findViewById(R.id.naProper);
		sAir = (CheckBox) getView().findViewById(R.id.sAir);
		nsAir = (CheckBox) getView().findViewById(R.id.nsAir);
		naAir = (CheckBox) getView().findViewById(R.id.naAir);
		sRescue = (CheckBox) getView().findViewById(R.id.sRescue);
		nsRescue = (CheckBox) getView().findViewById(R.id.nsRescue);
		naRescue = (CheckBox) getView().findViewById(R.id.naRescue);
		sSafety = (CheckBox) getView().findViewById(R.id.sSafety);
		nsSafety = (CheckBox) getView().findViewById(R.id.nsSafety);
		naSafety = (CheckBox) getView().findViewById(R.id.naSafety);
		sSecond = (CheckBox) getView().findViewById(R.id.sSecond);
		nsSecond = (CheckBox) getView().findViewById(R.id.nsSecond);
		naSecond = (CheckBox) getView().findViewById(R.id.naSecond);
		sOutGoing = (CheckBox) getView().findViewById(R.id.sOutgoing);
		nsOutGoing = (CheckBox) getView().findViewById(R.id.nsOutgoing);
		naOutGoing = (CheckBox) getView().findViewById(R.id.naOutgoing);
		sPermit = (CheckBox) getView().findViewById(R.id.spermit);
		nsPermit = (CheckBox) getView().findViewById(R.id.nspermit);
		naPermit = (CheckBox) getView().findViewById(R.id.napermit);
		sOther6 = (CheckBox) getView().findViewById(R.id.sOther6);
		nsOther6 = (CheckBox) getView().findViewById(R.id.nsOther6);
		naOther6 = (CheckBox) getView().findViewById(R.id.naOther6);

		cb71 = (CheckBox) getView().findViewById(R.id.cb71);
		cb72 = (CheckBox) getView().findViewById(R.id.cb72);
		cb73 = (CheckBox) getView().findViewById(R.id.cb73);
		sMaster = (CheckBox) getView().findViewById(R.id.sMaster);
		nsMaster = (CheckBox) getView().findViewById(R.id.nsMaster);
		naMaster = (CheckBox) getView().findViewById(R.id.naMaster);
		sExtinguishers = (CheckBox) getView().findViewById(R.id.sExtinguishers);
		nsExtinguishers = (CheckBox) getView().findViewById(R.id.nsExtinguishers);
		naExtinguishers = (CheckBox) getView().findViewById(R.id.naExtinguishers);
		sFully = (CheckBox) getView().findViewById(R.id.sFully);
		nsFully = (CheckBox) getView().findViewById(R.id.nsFully);
		naFully = (CheckBox) getView().findViewById(R.id.naFully);
		sAdequately = (CheckBox) getView().findViewById(R.id.sAdequately);
		nsAdequately = (CheckBox) getView().findViewById(R.id.nsAdequately);
		naAdequately = (CheckBox) getView().findViewById(R.id.naAdequately);
		sOther8 = (CheckBox) getView().findViewById(R.id.sOther8);
		nsOther8 = (CheckBox) getView().findViewById(R.id.nsOther8);
		naOther8 = (CheckBox) getView().findViewById(R.id.naOther8);

		cb81 = (CheckBox) getView().findViewById(R.id.cb81);
		cb82 = (CheckBox) getView().findViewById(R.id.cb82);
		cb83 = (CheckBox) getView().findViewById(R.id.cb83);
		sRods = (CheckBox) getView().findViewById(R.id.sRods);
		nsRods = (CheckBox) getView().findViewById(R.id.nsRods);
		naRods = (CheckBox) getView().findViewById(R.id.naRods);
		sMSDs = (CheckBox) getView().findViewById(R.id.sMSDs);
		nsMSDs = (CheckBox) getView().findViewById(R.id.nsMSDs);
		naMSDs = (CheckBox) getView().findViewById(R.id.naMSDs);
		sProper2 = (CheckBox) getView().findViewById(R.id.sProper);
		nsProper2 = (CheckBox) getView().findViewById(R.id.nsProper);
		naProper2 = (CheckBox) getView().findViewById(R.id.naProper);
		sexhaust = (CheckBox) getView().findViewById(R.id.sexhaust);
		nsexhaust = (CheckBox) getView().findViewById(R.id.nsexhaust);
		naexhaust = (CheckBox) getView().findViewById(R.id.naexhaust);
		scylinders = (CheckBox) getView().findViewById(R.id.scylinders);
		nscylinders = (CheckBox) getView().findViewById(R.id.nscylinders);
		nacylinders = (CheckBox) getView().findViewById(R.id.nacylinders);
		sExtiguisher = (CheckBox) getView().findViewById(R.id.sExtiguisher);
		nsExtiguisher = (CheckBox) getView().findViewById(R.id.nsExtiguisher);
		naExtiguisher = (CheckBox) getView().findViewById(R.id.naExtiguisher);
		sOther9 = (CheckBox) getView().findViewById(R.id.sOther9);
		nsOther9 = (CheckBox) getView().findViewById(R.id.nsOther9);
		naOther9 = (CheckBox) getView().findViewById(R.id.naOther9);

		cb91 = (CheckBox) getView().findViewById(R.id.cb91);
		cb92 = (CheckBox) getView().findViewById(R.id.cb92);
		cb93 = (CheckBox) getView().findViewById(R.id.cb93);
		sOutdoor = (CheckBox) getView().findViewById(R.id.sOutdoor);
		nsOutdoor =(CheckBox) getView().findViewById(R.id.nsOutdoor);
		naOutdoor =(CheckBox) getView().findViewById(R.id.naOutdoor);
		sCondition =(CheckBox) getView().findViewById(R.id.sCondition);
		nsCondition=(CheckBox) getView().findViewById(R.id.nsCondition);
		naCondition=(CheckBox) getView().findViewById(R.id.naCondition);
		sProperly2 =(CheckBox) getView().findViewById(R.id.sProperly);
		nsProperly2 =(CheckBox) getView().findViewById(R.id.nsProperly);
		naProperly2 =(CheckBox) getView().findViewById(R.id.naProperly);
		sGFCIs =(CheckBox) getView().findViewById(R.id.sGFCIs);
		nsGFCIs =(CheckBox) getView().findViewById(R.id.nsGFCIs);
		naGFCIs =(CheckBox) getView().findViewById(R.id.naGFCIs);
		sOther10 =(CheckBox) getView().findViewById(R.id.sOther10);
		nsOther10 =(CheckBox) getView().findViewById(R.id.nsOther10);
		naOther10 =(CheckBox) getView().findViewById(R.id.naOther10);


		cb1.setOnClickListener(this);
		cb2.setOnClickListener(this);
		cb3.setOnClickListener(this);
		cb21.setOnClickListener(this);
		cb22.setOnClickListener(this);
		cb23.setOnClickListener(this);
		cb31.setOnClickListener(this);
		cb32.setOnClickListener(this);
		cb33.setOnClickListener(this);
		cb41.setOnClickListener(this);
		cb42.setOnClickListener(this);
		cb43.setOnClickListener(this);
		cb51.setOnClickListener(this);
		cb52.setOnClickListener(this);
		cb53.setOnClickListener(this);
		cb61.setOnClickListener(this);
		cb62.setOnClickListener(this);
		cb63.setOnClickListener(this);
		cb71.setOnClickListener(this);
		cb72.setOnClickListener(this);
		cb73.setOnClickListener(this);
		cb81.setOnClickListener(this);
		cb82.setOnClickListener(this);
		cb83.setOnClickListener(this);
		cb91.setOnClickListener(this);
		cb92.setOnClickListener(this);
		cb93.setOnClickListener(this);

		etEmployeeName.setOnClickListener(this);
		etLocation.setOnClickListener(this);
		etConducted.setOnClickListener(this);

		submit = (Button) getView().findViewById(R.id.submit);
		submit.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.imageView1:
			if (ttSiteAcess.getVisibility() == View.VISIBLE) {
				ttSiteAcess.setVisibility(View.GONE);
				imSiteAcess.setImageResource(R.drawable.expand);
			} else {
				imSiteAcess.setImageResource(R.drawable.collapse);
				ttSiteAcess.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView2:
			if (ttHousekepping.getVisibility() == View.VISIBLE) {
				ttHousekepping.setVisibility(View.GONE);
				imHousekepping.setImageResource(R.drawable.expand);
			} else {
				imHousekepping.setImageResource(R.drawable.collapse);
				ttHousekepping.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView3:
			if (ttpersonalProtectiveEquipment.getVisibility() == View.VISIBLE) {
				ttpersonalProtectiveEquipment.setVisibility(View.GONE);
				impersonalProtectiveEquipment
				.setImageResource(R.drawable.expand);
			} else {
				impersonalProtectiveEquipment
				.setImageResource(R.drawable.collapse);
				ttpersonalProtectiveEquipment.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView4:
			if (ttPowerTools.getVisibility() == View.VISIBLE) {
				impersonalProtectiveEquipment
				.setImageResource(R.drawable.expand);
				ttPowerTools.setVisibility(View.GONE);
			} else {
				imPowerTools.setImageResource(R.drawable.collapse);
				ttPowerTools.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView5:
			if (ttStairwells.getVisibility() == View.VISIBLE) {
				imStairwells.setImageResource(R.drawable.expand);
				ttStairwells.setVisibility(View.GONE);
			} else {
				imStairwells.setImageResource(R.drawable.collapse);
				ttStairwells.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView6:
			if (ttConfinedspaces.getVisibility() == View.VISIBLE) {
				imConfinedspaces.setImageResource(R.drawable.expand);
				ttConfinedspaces.setVisibility(View.GONE);
			} else {
				imConfinedspaces.setImageResource(R.drawable.collapse);
				ttConfinedspaces.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView7:
			if (ttFireProtection.getVisibility() == View.VISIBLE) {
				imFireProtection.setImageResource(R.drawable.expand);
				ttFireProtection.setVisibility(View.GONE);
			} else {
				imFireProtection.setImageResource(R.drawable.collapse);
				ttFireProtection.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView8:
			if (ttWelding.getVisibility() == View.VISIBLE) {
				imWelding.setImageResource(R.drawable.expand);
				ttWelding.setVisibility(View.GONE);
			} else {
				imSiteAcess.setImageResource(R.drawable.collapse);
				ttWelding.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView9:
			if (ttExtension.getVisibility() == View.VISIBLE) {
				imExtension.setImageResource(R.drawable.expand);
				ttExtension.setVisibility(View.GONE);
			} else {
				imExtension.setImageResource(R.drawable.collapse);
				ttExtension.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView10:
			if (ttMaterials.getVisibility() == View.VISIBLE) {
				imMaterials.setImageResource(R.drawable.expand);
				ttMaterials.setVisibility(View.GONE);
			} else {
				imMaterials.setImageResource(R.drawable.collapse);
				ttMaterials.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView11:
			if (ttSignsandPrint.getVisibility() == View.VISIBLE) {
				imSignsandPrint.setImageResource(R.drawable.expand);
				ttSignsandPrint.setVisibility(View.GONE);
			} else {
				imSignsandPrint.setImageResource(R.drawable.collapse);
				ttSignsandPrint.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView12:
			if (ttWorker.getVisibility() == View.VISIBLE) {
				imWorker.setImageResource(R.drawable.expand);
				ttWorker.setVisibility(View.GONE);
			} else {
				imWorker.setImageResource(R.drawable.collapse);
				ttWorker.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.imageView13:
			if (ttHygiene.getVisibility() == View.VISIBLE) {
				imHygiene.setImageResource(R.drawable.expand);
				ttHygiene.setVisibility(View.GONE);
			} else {
				imHygiene.setImageResource(R.drawable.collapse);
				ttHygiene.setVisibility(View.VISIBLE);
			}
			break;
		case R.id.etLocation:
			AccountLookup acLookUp = new AccountLookup();
			acLookUp.accountLookupDetails(getActivity(), "ERT");
			break;
		case R.id.etConductedBy:
			TechicianNameLookup siteworker = new TechicianNameLookup();
			siteworker.getItemLookUp(getActivity(), "site");
			break;
		case R.id.etEmployee:
			TechicianNameLookup inspection = new TechicianNameLookup();
			inspection.getItemLookUp(getActivity(), "inspection");
			break;

		case R.id.submit:
			insertNewERTDevice();
			break;

		case R.id.cb1:
			if (cb1.isChecked()) {
				sClean.setChecked(true);
				sAdequate.setChecked(true);
				sAdequateLadders.setChecked(true);
				sother.setChecked(true);
			} else {

				sClean.setChecked(false);
				sAdequate.setChecked(false);
				sAdequateLadders.setChecked(false);
				sother.setChecked(false);

			}
			break;
		case R.id.cb2:

			if (cb2.isChecked()) {
				nsClean.setChecked(true);
				nsAdequate.setChecked(true);
				nsAdequateLadders.setChecked(true);
				nsother.setChecked(true);
			} else {
				nsClean.setChecked(false);
				nsAdequate.setChecked(false);
				nsAdequateLadders.setChecked(false);
				nsother.setChecked(false);

			}
			break;
		case R.id.cb3:

			if (cb3.isChecked()) {
				naClean.setChecked(true);
				naAdequate.setChecked(true);
				naAdequateLadders.setChecked(true);
				naother.setChecked(true);
			} else {
				naClean.setChecked(false);
				naAdequate.setChecked(false);
				naAdequateLadders.setChecked(false);
				naother.setChecked(false);

			}
			break;
		case R.id.cb81:
			if (cb81.isChecked()) {
				sRods.setChecked(true);
				sMSDs.setChecked(true);
				sProper2.setChecked(true);
				sexhaust.setChecked(true);
				scylinders.setChecked(true);
				sExtiguisher.setChecked(true);
				sOther9.setChecked(true);
			} else {
				sRods.setChecked(false);
				sMSDs.setChecked(false);
				sProper2.setChecked(false);
				sexhaust.setChecked(false);
				scylinders.setChecked(false);
				sExtiguisher.setChecked(false);
				sOther9.setChecked(false);

			}
			break;
		case R.id.cb82:

			if (cb82.isChecked()) {
				nsRods.setChecked(true);
				nsMSDs.setChecked(true);
				nsProper2.setChecked(true);
				nsexhaust.setChecked(true);
				nscylinders.setChecked(true);
				nsExtiguisher.setChecked(true);
				nsOther9.setChecked(true);
			} else {
				nsRods.setChecked(false);
				nsMSDs.setChecked(false);
				nsProper2.setChecked(false);
				nsexhaust.setChecked(false);
				nscylinders.setChecked(false);
				nsExtiguisher.setChecked(false);
				nsOther9.setChecked(false);

			}
			break;
		case R.id.cb83:

			if (cb83.isChecked()) {
				naRods.setChecked(true);
				naMSDs.setChecked(true);
				naProper2.setChecked(true);
				naexhaust.setChecked(true);
				nacylinders.setChecked(true);
				naExtiguisher.setChecked(true);
				naOther9.setChecked(true);
			} else {
				naRods.setChecked(false);
				naMSDs.setChecked(false);
				naProper2.setChecked(false);
				naexhaust.setChecked(false);
				nacylinders.setChecked(false);
				naExtiguisher.setChecked(false);
				naOther9.setChecked(false);

			}
			break;
		case R.id.cb61:
			if (cb61.isChecked()) {
				sCProper.setChecked(true);
				sAir.setChecked(true);
				sSafety.setChecked(true);
				sRescue.setChecked(true);
				sOutGoing.setChecked(true);
				sPermit.setChecked(true);
				sOther6.setChecked(true);
				sSecond.setChecked(true);
			} else {

				sCProper.setChecked(false);
				sAir.setChecked(false);
				sSafety.setChecked(false);
				sRescue.setChecked(false);
				sOutGoing.setChecked(false);
				sPermit.setChecked(false);
				sOther6.setChecked(false);
				sSecond.setChecked(false);

			}
			break;
		case R.id.cb62:

			if (cb62.isChecked()) {
				nsCproper.setChecked(true);
				nsAir.setChecked(true);
				nsSafety.setChecked(true);
				nsRescue.setChecked(true);
				nsOutGoing.setChecked(true);
				nsPermit.setChecked(true);
				nsOther6.setChecked(true);
				nsSecond.setChecked(true);
			} else {

				nsCproper.setChecked(false);
				nsAir.setChecked(false);
				nsSafety.setChecked(false);
				nsRescue.setChecked(false);
				nsOutGoing.setChecked(false);
				nsPermit.setChecked(false);
				nsOther6.setChecked(false);
				nsSecond.setChecked(false);

			}
			break;
		case R.id.cb63:

			if (cb63.isChecked()) {
				naCProper.setChecked(true);
				naAir.setChecked(true);
				naSafety.setChecked(true);
				naRescue.setChecked(true);
				naOutGoing.setChecked(true);
				naPermit.setChecked(true);
				naOther6.setChecked(true);
				naSecond.setChecked(true);
			} else {

				naCProper.setChecked(false);
				naAir.setChecked(false);
				naSafety.setChecked(false);
				naRescue.setChecked(false);
				naOutGoing.setChecked(false);
				naPermit.setChecked(false);
				naOther6.setChecked(false);
				naSecond.setChecked(false);

			}
			break;
		case R.id.cb41:
			if (cb41.isChecked()) {
				sGeneral.setChecked(true);
				sProper.setChecked(true);
				sOther4.setChecked(true);
			} else {

				sGeneral.setChecked(false);
				sProper.setChecked(false);
				sOther4.setChecked(false);

			}
			break;
		case R.id.cb42:

			if (cb42.isChecked()) {
				nsGeneral.setChecked(true);
				nsProper.setChecked(true);
				nsOther4.setChecked(true);
			} else {

				nsGeneral.setChecked(false);
				nsProper.setChecked(false);
				nsOther4.setChecked(false);

			}
			break;
		case R.id.cb43:

			if (cb43.isChecked()) {
				naGeneral.setChecked(true);
				naProper.setChecked(true);
				naOther4.setChecked(true);
			} else {

				naGeneral.setChecked(false);
				naProper.setChecked(false);
				naOther4.setChecked(false);

			}
			break;
		case R.id.cb51:
			if (cb51.isChecked()) {
				sLighting.setChecked(true);
				sHandRails.setChecked(true);
				sOther5.setChecked(true);
			} else {

				sLighting.setChecked(false);
				sHandRails.setChecked(false);
				sOther5.setChecked(false);

			}
			break;
		case R.id.cb52:

			if (cb52.isChecked()) {
				nsLighting.setChecked(true);
				nsHandRails.setChecked(true);
				nsOther5.setChecked(true);
			} else {

				nsLighting.setChecked(false);
				nsHandRails.setChecked(false);
				nsOther5.setChecked(false);

			}
			break;
		case R.id.cb53:

			if (cb53.isChecked()) {
				naLighting.setChecked(true);
				naHandRails.setChecked(true);
				naOther5.setChecked(true);
			} else {

				naLighting.setChecked(false);
				naHandRails.setChecked(false);
				naOther5.setChecked(false);

			}
			break;
		case R.id.cb21:
			if (cb21.isChecked()) {
				sWalkways.setChecked(true);
				sClearWork.setChecked(true);
				sAccessandLanding.setChecked(true);
				sOther2.setChecked(true);
			} else {

				sWalkways.setChecked(false);
				sClearWork.setChecked(false);
				sAccessandLanding.setChecked(false);
				sOther2.setChecked(false);

			}
			break;
		case R.id.cb22:

			if (cb22.isChecked()) {
				nsWalkways.setChecked(true);
				nsClearWork.setChecked(true);
				nsAccessandLanding.setChecked(true);
				nsOther2.setChecked(true);
			} else {

				nsWalkways.setChecked(false);
				nsClearWork.setChecked(false);
				nsAccessandLanding.setChecked(false);
				nsOther2.setChecked(false);

			}
			break;
		case R.id.cb23:

			if (cb23.isChecked()) {
				naWalkways.setChecked(true);
				naClearWork.setChecked(true);
				naAccessandLanding.setChecked(true);
				naOther2.setChecked(true);
			} else {

				naWalkways.setChecked(false);
				naClearWork.setChecked(false);
				naAccessandLanding.setChecked(false);
				naOther2.setChecked(false);

			}
			break;

		case R.id.cb31:
			if (cb31.isChecked()) {
				sHead.setChecked(true);
				sFoot.setChecked(true);
				sEye.setChecked(true);
				sHearing.setChecked(true);
				sRespiratory.setChecked(true);
				sfall.setChecked(true);
				sOther3.setChecked(true);
			} else {

				sHead.setChecked(false);
				sFoot.setChecked(false);
				sRespiratory.setChecked(false);
				sEye.setChecked(false);
				sHearing.setChecked(false);
				sfall.setChecked(false);
				sOther3.setChecked(false);

			}
			break;
		case R.id.cb32:

			if (cb32.isChecked()) {
				nsHead.setChecked(true);
				nsFoot.setChecked(true);
				nsEye.setChecked(true);
				nsHearing.setChecked(true);
				nsRespiratory.setChecked(true);
				nsFall.setChecked(true);
				nsOther3.setChecked(true);
			} else {

				nsHead.setChecked(false);
				nsFoot.setChecked(false);
				nsEye.setChecked(false);
				nsHearing.setChecked(false);
				nsRespiratory.setChecked(false);
				nsFall.setChecked(false);
				nsOther3.setChecked(false);

			}
			break;
		case R.id.cb33:

			if (cb33.isChecked()) {
				naHead.setChecked(true);
				naFoot.setChecked(true);
				naEye.setChecked(true);
				naHearing.setChecked(true);
				naRespiratory.setChecked(true);
				naFall.setChecked(true);
				naOther3.setChecked(true);
			} else {

				naHead.setChecked(false);
				naFoot.setChecked(false);
				naEye.setChecked(false);
				naHearing.setChecked(false);
				naRespiratory.setChecked(false);
				naFall.setChecked(false);
				naOther3.setChecked(false);

			}
			break;
		case R.id.cb71:
			if (cb71.isChecked()) {
				sMaster.setChecked(true);
				sExtinguishers.setChecked(true);
				sFully.setChecked(true);
				sAdequately.setChecked(true);
				sOther8.setChecked(true);
			} else {
				sMaster.setChecked(false);
				sExtinguishers.setChecked(false);
				sFully.setChecked(false);
				sAdequately.setChecked(false);
				sOther8.setChecked(false);
			}
			break;
		case R.id.cb72:
			if (cb72.isChecked()) {
				nsMaster.setChecked(true);
				nsExtinguishers.setChecked(true);
				nsFully.setChecked(true);
				nsAdequately.setChecked(true);
				nsOther8.setChecked(true);
			} else {
				nsMaster.setChecked(false);
				nsExtinguishers.setChecked(false);
				nsFully.setChecked(false);
				nsAdequately.setChecked(false);
				nsOther8.setChecked(false);
			}
			break;
		case R.id.cb73:
			if (cb73.isChecked()) {
				naMaster.setChecked(true);
				naExtinguishers.setChecked(true);
				naFully.setChecked(true);
				naAdequately.setChecked(true);
				naOther8.setChecked(true);
			} else {
				naMaster.setChecked(false);
				naExtinguishers.setChecked(false);
				naFully.setChecked(false);
				naAdequately.setChecked(false);
				naOther8.setChecked(false);
			}
			break;
		case R.id.cb91:
			if(cb91.isChecked()){
				sOutdoor.setChecked(true);
				sCondition.setChecked(true);
				sProperly2.setChecked(true);
				sGFCIs.setChecked(true);
				sOther10.setChecked(true);
			}else{
				sOutdoor.setChecked(false);
				sCondition.setChecked(false);
				sProperly2.setChecked(false);
				sGFCIs.setChecked(false);
				sOther10.setChecked(false);
			}
			break;
		case R.id.cb92:
			if(cb92.isChecked()){
				nsOutdoor.setChecked(true);
				nsCondition.setChecked(true);
				nsProperly2.setChecked(true);
				nsGFCIs.setChecked(true);
				nsOther10.setChecked(true);
			}else{
				nsOutdoor.setChecked(false);
				nsCondition.setChecked(false);
				nsProperly2.setChecked(false);
				nsGFCIs.setChecked(false);
				nsOther10.setChecked(false);
			}
			break;
		case R.id.cb93:
			if(cb93.isChecked()){
				naOutdoor.setChecked(true);
				naCondition.setChecked(true);
				naProperly2.setChecked(true);
				naGFCIs.setChecked(true);
				naOther10.setChecked(true);
			}else{
				naOutdoor.setChecked(false);
				naCondition.setChecked(false);
				naProperly2.setChecked(false);
				naGFCIs.setChecked(false);
				naOther10.setChecked(false);
			}
			break;

		default:
			break;
		}

	}

	private void insertNewERTDevice() {

		// textView is the TextView view that should display it
		String objectType = "Jobsite_Inspection_Checklist__c";
		HashMap<String, Object> fields = new HashMap<String, Object>();
		fields.put("Employee_Name__c", Session.sTechnicianId);
		fields.put("Location__c", Session.sAccountId);
		fields.put("Conduct_By__c", Session.sTechnicianId);
		fields.put("No_of_Employees__c", etNo_of_employees.getText().toString());
		// fields.put("Date__c", formattedDate);

		fields.put("Site_Access_S__c", cb1.isChecked());
		fields.put("Site_Access_NS__c", cb2.isChecked());
		fields.put("Site_Access_NA__c", cb3.isChecked());
		fields.put("Site_Access1_S__c", sClean.isChecked());
		fields.put("Site_Access1_NS__c", nsClean.isChecked());
		fields.put("Site_Access1_NA__c", naClean.isChecked());
		fields.put("Site_Access2_S__c", sAdequate.isChecked());
		fields.put("Site_Access2_NS__c", nsAdequate.isChecked());
		fields.put("Site_Access2_NA__c", naAdequate.isChecked());
		fields.put("Site_Access3_S__c", sAdequateLadders.isChecked());
		fields.put("Site_Access3_NS__c", nsAdequateLadders.isChecked());
		fields.put("Site_Access3_NA__c", naAdequateLadders.isChecked());
		fields.put("Site_Access4_S__c", sother.isChecked());
		fields.put("Site_Access4_NS__c", nsother.isChecked());
		fields.put("Site_Access4_NA__c", naother.isChecked());

		fields.put("House_Keeping_S__c", cb21.isChecked());
		fields.put("House_Keeping_NS__c", cb22.isChecked());
		fields.put("House_Keeping_NA__c", cb23.isChecked());
		fields.put("Housekeeping1_S__c", sWalkways.isChecked());
		fields.put("Housekeeping1_NS__c", nsWalkways.isChecked());
		fields.put("Housekeeping1_NA__c", naWalkways.isChecked());
		fields.put("Housekeeping2_S__c", sClearWork.isChecked());
		fields.put("Housekeeping2_NS__c", nsClearWork.isChecked());
		fields.put("Housekeeping2_NA__c", naClearWork.isChecked());
		fields.put("Housekeeping3_S__c", sAccessandLanding.isChecked());
		fields.put("Housekeeping3_NS__c", nsAccessandLanding.isChecked());
		fields.put("Housekeeping3_NA__c", naAccessandLanding.isChecked());
		fields.put("Housekeeping4_S__c", sOther2.isChecked());
		fields.put("Housekeeping4_NS__c", nsOther2.isChecked());
		fields.put("Housekeeping4_NA__c", naOther2.isChecked());

		fields.put("Personal_Protective_Equipment_S__c", cb31.isChecked());
		fields.put("Personal_Protective_Equipment_NS__c", cb32.isChecked());
		fields.put("Personal_Protective_Equipment_NA__c", cb33.isChecked());
		fields.put("Pesonal_protective_equipment1_S__c", sHead.isChecked());
		fields.put("Pesonal_protective_equipment1_NS__c", nsHead.isChecked());
		fields.put("Pesonal_protective_equipment1_NA__c", naHead.isChecked());
		fields.put("Pesonal_protective_equipment2_S__c", sFoot.isChecked());
		fields.put("Pesonal_protective_equipment2_NS__c", nsFoot.isChecked());
		fields.put("Pesonal_protective_equipment2_NA__c", naFoot.isChecked());
		fields.put("Pesonal_protective_equipment3_S__c", sEye.isChecked());
		fields.put("Pesonal_protective_equipment3_NS__c", nsEye.isChecked());
		fields.put("Pesonal_protective_equipment3_NA__c", naEye.isChecked());
		fields.put("Pesonal_protective_equipment4_S__c", sHearing.isChecked());
		fields.put("Pesonal_protective_equipment4_NS__c", nsHearing.isChecked());
		fields.put("Pesonal_protective_equipment4_NA__c", naHearing.isChecked());
		fields.put("Pesonal_protective_equipment5_S__c",
				sRespiratory.isChecked());
		fields.put("Pesonal_protective_equipment5_NS__c",
				nsRespiratory.isChecked());
		fields.put("Pesonal_protective_equipment5_NA__c",
				naRespiratory.isChecked());
		fields.put("Pesonal_protective_equipment6_S__c", sfall.isChecked());
		fields.put("Pesonal_protective_equipment6_NS__c", nsFall.isChecked());
		fields.put("Pesonal_protective_equipment6_NA__c", naFall.isChecked());
		fields.put("Pesonal_protective_equipment7_S__c", sOther3.isChecked());
		fields.put("Pesonal_protective_equipment7_NS__c", naOther3.isChecked());
		fields.put("Pesonal_protective_equipment7_NA__c", naOther3.isChecked());


		fields.put("Power_Tools_Equipment_S__c", cb41.isChecked());
		fields.put("Power_Tools_Equipment_NS__c", cb42.isChecked());
		fields.put("Power_Tools_Equipment_NA__c", cb43.isChecked());
		fields.put("Power_tools_equipment1_S__c", sGeneral.isChecked());
		fields.put("Power_tools_equipment1_NS__c", nsGeneral.isChecked());
		fields.put("Power_tools_equipment1_NA__c", naGeneral.isChecked());
		fields.put("Power_tools_equipment2_S__c", sProper.isChecked());
		fields.put("Power_tools_equipment2_NS__c", nsProper.isChecked());
		fields.put("Power_tools_equipment2_NA__c", naProper.isChecked());
		/*fields.put("Power_tools_equipment3_S__c", sOther4.isChecked());
		fields.put("Power_tools_equipment3_NS__c", sOther4.isChecked());
		fields.put("Power_tools_equipment3_NA__c", sOther4.isChecked());*/
		fields.put("Power_tools_equipment4_S__c", sOther4.isChecked());
		fields.put("Power_tools_equipment4_NS__c",nsOther4.isChecked());
		fields.put("Power_tools_equipment4_NA__c", naOther4.isChecked());




		fields.put("Stairwells_and_Ramps_S__c", cb51.isChecked());
		fields.put("Stairwells_and_Ramps_NS__c", cb52.isChecked());
		fields.put("Stairwells_and_Ramps_NA__c", cb53.isChecked());
		fields.put("Stairwells_Ramps1_S__c", sLighting.isChecked());
		fields.put("Stairwells_Ramps1_NS__c", nsLighting.isChecked());
		fields.put("Stairwells_Ramps1_NA__c", naLighting.isChecked());
		fields.put("Stairwells_Ramps2_S__c", sHandRails.isChecked());
		fields.put("Stairwells_Ramps2_NS__c", nsHandRails.isChecked());
		fields.put("Stairwells_Ramps2_NA__c", naHandRails.isChecked());
		fields.put("Stairwells_Ramps3_S__c", sOther5.isChecked());
		fields.put("Stairwells_Ramps3_NS__c", nsOther5.isChecked());
		fields.put("Stairwells_Ramps3_NA__c", naOther5.isChecked());




		fields.put("Confined_Spaces_S__c", cb61.isChecked());
		fields.put("Confined_Spaces_NS__c", cb62.isChecked());
		fields.put("Confined_Spaces_NA__c", cb63.isChecked());
		fields.put("Confined_Spaces1_S__c", sCProper.isChecked());
		fields.put("Confined_Spaces1_NS__c", nsCproper.isChecked());
		fields.put("Confined_Spaces1_NA__c", naCProper.isChecked());
		fields.put("Confined_Spaces2_S__c", sSafety.isChecked());
		fields.put("Confined_Spaces2_NS__c", nsSafety.isChecked());
		fields.put("Confined_Spaces2_NA__c", naSafety.isChecked());
		fields.put("Confined_Spaces3_S__c", sRescue.isChecked());
		fields.put("Confined_Spaces3_NS__c", nsRescue.isChecked());
		fields.put("Confined_Spaces3_NA__c", naRescue.isChecked());
		fields.put("Confined_Spaces4_S__c", sOutGoing.isChecked());
		fields.put("Confined_Spaces4_NS__c", nsOutGoing.isChecked());
		fields.put("Confined_Spaces4_NA__c", naOutGoing.isChecked());
		fields.put("Confined_Spaces5_S__c", sPermit.isChecked());
		fields.put("Confined_Spaces5_NS__c", nsPermit.isChecked());
		fields.put("Confined_Spaces5_NA__c", naPermit.isChecked());
		fields.put("Confined_Spaces6_S__c", sSecond.isChecked());
		fields.put("Confined_Spaces6_NS__c", nsSecond.isChecked());
		fields.put("Confined_Spaces6_NA__c", naSecond.isChecked());
		/*fields.put("Confined_Spaces7_S__c", sfall.isChecked());
		fields.put("Confined_Spaces7_NS__c", nsFall.isChecked());
		fields.put("Confined_Spaces7_NA__c", naFall.isChecked());*/
		fields.put("Confined_Spaces8_S__c", sOther6.isChecked());
		fields.put("Confined_Spaces8_NS__c", nsOther6.isChecked());
		fields.put("Confined_Spaces8_NA__c", naOther6.isChecked());




		fields.put("Fire_Protection_S__c", cb71.isChecked());
		fields.put("Fire_Protection_NS__c", cb72.isChecked());
		fields.put("Fire_Protection_NA__c", cb73.isChecked());
		fields.put("Fire_Protection1_S__c", sMaster.isChecked());
		fields.put("Fire_Protection1_NS__c", nsMaster.isChecked());
		fields.put("Fire_Protection1_NA__c", naMaster.isChecked());
		fields.put("Fire_Protection2_S__c", sExtinguishers.isChecked());
		fields.put("Fire_Protection2_NS__c", nsExtinguishers.isChecked());
		fields.put("Fire_Protection2_NA__c", naExtinguishers.isChecked());
		fields.put("Fire_Protection3_S__c", sFully.isChecked());
		fields.put("Fire_Protection3_NS__c", nsFully.isChecked());
		fields.put("Fire_Protection3_NA__c", naFully.isChecked());
		fields.put("Fire_Protection4_S__c", sAdequately.isChecked());
		fields.put("Fire_Protection4_NS__c", nsAdequately.isChecked());
		fields.put("Fire_Protection4_NA__c", naAdequately.isChecked());
		fields.put("Fire_Protection5_S__c", sOther8.isChecked());
		fields.put("Fire_Protection5_NS__c", nsOther8.isChecked());
		fields.put("Fire_Protection5_NA__c", naOther8.isChecked());




		try {
			RestRequest restRequest = RestRequest.getRequestForCreate(
					Bean_Class.api_Version, objectType, fields);

			client.sendAsync(restRequest, new AsyncRequestCallback() {
				@Override
				public void onSuccess(RestRequest request, RestResponse result) {
					try {
						Log.i("NCS", "Response is  :" + result);
						finishFragment();
					} catch (Exception e) {
						Log.i("TPT", "Exception is   :" + e.getMessage());
					}
				}

				@Override
				public void onError(Exception exception) {
					EventsObservable.get().notifyEvent(
							EventType.RenditionComplete);
				}
			});
		} catch (Exception e) {
			Log.i("NCS", "Exception is   :" + e.getMessage());

		}

	}

	public void finishFragment() {
		getActivity().getSupportFragmentManager().beginTransaction()
		.remove(this).commit();
	}

}
